﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using SportsStore.Domain.Abstract;

namespace SportsStore.WebUI.Controllers
{
    public class NavController : Controller
    {
        public IProductRepository Repository { get; set; }

        public NavController( IProductRepository repository )
        {
            this.Repository = repository;
        }

        public PartialViewResult Menu( string category = null )
        {
            ViewBag.SelectedCategory = category;

            IEnumerable<string> categories = this.Repository.Products
                .Select( product => product.Category )
                .Distinct()
                .OrderBy( product => product );

            return PartialView( categories );
        }
    }
}
